<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="模板编码" prop="appName">
        <el-input v-model="queryParams.templateCode" placeholder="请输入模板编码" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="handleQuery('reset')">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                   v-hasPermi="['infra:job:create']">新增</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="handleQuery"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="序号" align="center" width="120" type="index" />
      <el-table-column label="记录ID" align="center" prop="detailCode" />
      <el-table-column label="通道名称" align="center" prop="channelName" />
      <el-table-column label="发送方" align="center" prop="sendAccount" />
      <el-table-column label="接收方" align="center" prop="receiveAccount" />
      <el-table-column label="标题" align="center" prop="msgTile" />
      <el-table-column label="内容" align="center" prop="msgContent" />

      <el-table-column label="操作"  class-name="small-padding fixed-width" align="center">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="view(scope.row)"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="page.current" :limit.sync="page.size"
                @pagination="handleQuery"/>

    <el-dialog title="消息记录详情" :visible.sync="open" width="75%" @close="close" append-to-body>
      <el-form :model="dataForm" ref="dataForm">
        <el-row>
          <el-col :span="8">
            <el-form-item label="记录ID" prop="templateCode">
              <el-input disabled v-model="dataForm.detailCode" placeholder="请输入记录ID" clearable size="small" style="width: 240px"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="通道名称" prop="channelName">
              <el-input disabled v-model="dataForm.channelName" placeholder="请输入通道名称" clearable size="small" style="width: 240px"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="发送方" prop="sendAccount">
              <el-input disabled v-model="dataForm.sendAccount" placeholder="请输入发送方" clearable size="small" style="width: 240px"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="接收方" prop="receiveAccount">
              <el-input disabled v-model="dataForm.receiveAccount" placeholder="请输入接收方" clearable size="small" style="width: 240px"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="标题" prop="msgTile">
              <el-input disabled v-model="dataForm.msgTile" placeholder="请输入标题" clearable size="small" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="内容" prop="msgTile">
              <el-input disabled type="textarea"  :autosize="{ minRows: 8, maxRows: 10 }" v-model="dataForm.msgContent" placeholder="请输入内容" clearable size="small" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template slot="footer">
        <el-button size="mini" type="primary" @click="open = false">取 消</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script>
import {myMessageDetail} from '@/api/message/template'
export default {
  name: "index",
  data(){
    return{
      dataForm:{},
      queryParams:{
      },
      page:{
        current: 1,
        size: 10
      },
      open: false,
      showSearch: true,
      loading: false,
      dataList: [],
      total:0
    }
  },
  created() {
    this.handleQuery()
  },
  methods:{
    close:()=>{
      this.dataForm = {}
    },
    handleQuery(type){
      if (type == 'reset') this.queryParams = {}
      this.queryParams.templateCode = []
      myMessageDetail(this.page.current,this.page.size,this.queryParams).then(res=>{
        this.dataList = res.data.records
        this.total = res.data.total
      })
    },
    handleAdd(){

    },
    view(row){
      this.dataForm = row
      this.open = true
    }
  }
}
</script>

<style scoped>

</style>
